import sys
import os
MYPATH = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(MYPATH, "..", "comm"))

from shends import tree, md5sum, myjson

def get_md5():
    dd = {}

    path = r"E:\bakup\Picture\2021"
    for abs_path, relpath in tree(path):
        dd[relpath] = md5sum(abs_path)

    myjson(dd, r"E:\bakup\Picture\2021\file.json")

def copy_file():
    strs = open(r"E:\bakup\Picture\2021\file.json", "r").read()
    path = r"E:\mi\1"
    for abs_path, relpath in tree(path):
        #print(relpath)
        md5_str  = md5sum(abs_path)
        if md5_str in strs:
            os.remove(abs_path)
            print(abs_path)

copy_file()